#pragma once
#include"my_hash_map_set.h"
using namespace std;
namespace fertilizer
{
	template<class K, class V>
	class unordered_map
	{
		struct MapKeyOfT
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename my_hash_map_set::HashTable<K, pair<K, V>, MapKeyOfT>::const_iterator iterator;
		typedef typename my_hash_map_set::HashTable<K, pair<K, V>, MapKeyOfT>::const_iterator const_iterator;
		
		iterator begin() const
		{
			return _ht.begin();
		}

		iterator end() const
		{
			return _ht.end();
		}

		pair<iterator, bool> insert(const pair<K, V>& kv)
		{
			pair<typename my_hash_map_set::HashTable<K, pair<K, V>, MapKeyOfT>::iterator, bool> ret = _ht.insert(kv);
			return pair<iterator, bool>(ret.first, ret.second);
		}
		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _ht.insert(make_pair(key, V()));
			return ret.first->second;
		}
	private:
		my_hash_map_set::HashTable<K, pair<K, V>, MapKeyOfT> _ht;
	};
}
